import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:untitled/model/product.dart';
import 'package:untitled/pages/FlutterUI/Shopping/detail/product_detail.dart';
import 'package:untitled/utils/constants.dart';

class ProductItem extends StatelessWidget {
  final Size size;
  final Product? product;
  const ProductItem({Key? key, required this.size, this.product}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: (){
        Navigator.push(context, MaterialPageRoute(
            builder: (context){
              return ProductDetail();
            }
        ));
      },
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            width: (size.width -45)/2,
            height: (size.width -45)/2,
            decoration: BoxDecoration(
              color: product?.backgroundColor,
              borderRadius: BorderRadius.circular(16),
            ),
            child: Image.asset(
              product?.imageUrl as String
            ),
          ),
          SizedBox(height: 12,),
          Text(
            product?.title as String,
            style: TextStyle(
              fontSize: 14,
              color: mScroudTextColor
            ),
          ),
          Text(
            product?.price as String,
            style: TextStyle(
              color: mPrimaryTextColor,
              fontWeight: FontWeight.bold
            ),
          )
        ],
      ),

    );
    
  }
}